﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ciiattack
{
    public class Enemy : Actor
    {
        int score = 0;
        private SpriteFont _scr;

        public SpriteFont Score
        {
            get { return _scr; }
            set { _scr = value; }
        }

        public Enemy(Texture2D texture, Vector2 origin, SpriteBatch spriteBatch, Vector2 initialPosition)
            : base(texture, origin, spriteBatch, initialPosition)
        {
        }

        public override void Update(GameTime gameTime)
        {
            if (this.Position.Y < 512.0f) // Enemy is on the screen
            {
                this.Position += Vector2.UnitY * 4.0f; // Move down
            }
            else // Otherwise...
            {
                this.reset(); // reset()
            }

            base.Update(gameTime);
        }

        public void OnHit()
        {
            this.reset(); // reset()
        }

        private void reset()
        {
            Random random = new Random(); // Create a new Random instance

            this.Position = new Vector2(32.0f + random.Next(176), -32.0f - random.Next(256)); // Move back to the top of the screen
        }
    }
}